home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / du_lib / dulib.h < prev    next >
C/C++ Source or Header  |  1995-07-10  |  18KB  |  471 lines

  1. /*
  2.    DU_LIB v2
  3.    Gem Window Management & Dialog Library For Lattice C
  4.    ½1994,95, by Craig Graham.
  5.    Based on the DU_LIBv1 Library for HiSoft Basic.
  6.  
  7.    --->Library Header File
  8. */
  9.  
  10. #ifndef __DU_LIB__
  11. #define __DU_LIB__
  12.  
  13. /*#include <dos.h>*/
  14.  
  15. #ifndef FMSIZE
  16. #define FNSIZE 40    /* maximum file node size */
  17. #define FMSIZE 128    /* maximum file name size */
  18. #define FESIZE 20    /* maximum file extension size */
  19. #endif
  20.  
  21. #ifndef __USE_GNU
  22. #include <aes.h>
  23. #include <vdi.h>
  24. #else
  25. #include <aesbind.h>
  26. #include <vdibind.h>
  27. #endif
  28.  
  29. #include <xacc.h>            // Xacc2 handler library (should be included now)
  30.  
  31. #define max_windows            50
  32. #define max_dialogs            100
  33.  
  34. #define ob_sizeof            24
  35.  
  36. /* Winx stuff */
  37. #define WF_RETURN            1
  38. #define WF_WINX                22360
  39. #define    WF_WINXCFG            22361
  40. #define WF_OWNER            20
  41. #define WF_BOTTOM            25
  42. #define WM_BOTTOMED            33
  43.  
  44. /*DULIB custom messages*/
  45. #define WM_CUSTOM_REDRAW    100
  46.  
  47. #ifndef WF_BEVENT
  48. #define WF_BEVENT             24
  49. #define WM_UNTOPPED         30
  50. #define WM_ONTOP             31
  51. #define AP_TERM             50
  52. #endif
  53.  
  54. #ifndef DESK
  55. #define DESK                0
  56. #endif
  57.  
  58. /*ICFS & AES 5 stuff */
  59. #ifndef WF_ICONIFY 
  60. #define WF_ICONIFY                26
  61. #define WF_UNICONIFY            27
  62. #define WF_UNICONIFYXYWH        28
  63. #define WM_ICONIFY                34
  64. #define WM_UNICONIFY            35
  65. #define WM_ALLICONIFY            36
  66. #define SMALLER                    0x4000
  67. #endif
  68.  
  69. /* keyboard focus policy */
  70.  
  71. #define FOCUS_MOUSE                1
  72. #define FOCUS_FIELD                2
  73.  
  74. /* Drag'n'Drop */
  75. #ifndef AP_DRAGDROP
  76. #define AP_DRAGDROP            63
  77. #define    DD_OK                0
  78. #define DD_NAK                1
  79. #define DD_EXT                2
  80. #define DD_LEN                3
  81. #define DD_TRASH            4
  82. #define DD_PRINTER            5
  83. #define DD_CLIPBOARD        6
  84. #define DD_TIMEOUT            4000        /* timeout in milliseconds */
  85. #define DD_NUMEXTS            8
  86. #define DD_EXTSIZE            32L
  87. #define DD_NAMEMAX            128        /* max size of a drag&drop item name */
  88. #define DD_HDRMAX            (8+DD_NAMEMAX)    /* max length of a drag&drop header */
  89. #endif
  90.  
  91. /*Colour Icon stuff*/
  92. #ifndef G_CICON
  93. #define G_CICON                33
  94. #endif
  95.  
  96. /*Object flag masks*/
  97. #define mask_none            0
  98. #define mask_selectable        1
  99. #define mask_default        2
  100. #define mask_exit            4
  101. #define mask_editable        8
  102. #define mask_rbutton        16
  103. #define mask_lastob            32
  104. #define mask_touchexit        64
  105. #define mask_hidetree        128
  106. #define mask_indirect        256
  107. #define mask_indicator        512
  108. #define mask_activator        1024
  109.  
  110. /*Object state masks*/
  111. #define mask_normal            0
  112. #define mask_selected        1
  113. #define mask_crossed        2
  114. #define mask_checked        4
  115. #define mask_disabled        8
  116. #define mask_outlined        16
  117. #define mask_shadowed        32
  118.  
  119. /*Scrollable List Widget constants*/
  120. #define scroll_widget            0
  121. #define scroll_drag_background    1
  122. #define scroll_drag                2
  123. #define scroll_text_area        3
  124. #define scroll_up                4
  125. #define scroll_down                5
  126.  
  127. /* Booleans */
  128. #define TRUE    1
  129. #define FALSE    0
  130.  
  131. /* DULIB Mode Control Setables */
  132. typedef enum {
  133.     DU_MODE_RIGHT_EQUALS_DOUBLE,
  134.     DU_MODE_SCROLL_HIGHLIGHT_IS_INVERSE,
  135.     DU_MODE_KEYPRESS_TO_WINDOW_UNDER_MOUSE
  136. } ModeType;
  137.  
  138. typedef enum {
  139.     wrm_scale,
  140.     wrm_window,
  141.     wrm_abs
  142. } Dmode;
  143.  
  144. typedef enum{
  145.     DIAL_NO_CLOSE,
  146.     DIAL_ROLLUP,
  147.     DIAL_ROLLUP_BOTTOM_SCROLLER,
  148.     DIAL_ROLLUP_SIDE_SCROLLER,
  149.     DIAL_FIXED,
  150.     DIAL_WIDGET_BAR
  151. } dialog_type;
  152.  
  153. typedef enum {
  154.     wt_null,
  155.     wt_drawing,
  156.     wt_static_menu,
  157.     wt_alert,
  158.     wt_menu_bar,
  159.     wt_cro,
  160.     wt_dialog,
  161.     wt_dialog_side_bar,
  162.     wt_dialog_bottom_bar,
  163.     wt_iconified_drawing
  164. } Wtype;
  165.  
  166. typedef short event;
  167.  
  168. /* type for a callback function (pointer to a function) */
  169. typedef short (*CallBack)(void);
  170.  
  171. /*details of a scrolling text list*/
  172. typedef struct {
  173.     char *(*texts);    /*list contents*/
  174.     short current;    /*current highlighted option*/
  175.     short number;    /*number of options in list*/
  176.     short display;    /*number of lines to display*/
  177.     short start;    /*base for currently displayed lines*/
  178. } scroll_text;
  179.  
  180. /* one line of text in a linked list of text lines */
  181. typedef struct tl {
  182.     char *the_text;                /*array of chars containing the text*/
  183.     short eof_line;                /*count of characters on this line==end of line*/
  184.     struct tl* prev;
  185.     struct tl* next;
  186. } text_line;
  187.  
  188. /* text widget structure */
  189. typedef struct tp {
  190.     short max_lines;                /*maximum number of lines of text - 0 indicates unbounded */
  191.     short max_columns;                /*maximum number of columns == length of the char array text in the text line struct*/
  192.     short cursor_y;                    /*row which has cursor on it (displayed lines)*/
  193.     short current_column;            /*column which has the cursor on it*/
  194.     short display_lines_high;        /*the number of lines of text which will physically fit into the widget on screen*/
  195.     text_line *current_line;        /*pointer to line which has the cursor on it*/
  196.     text_line *text;                /*list of the actual texts in the widget*/
  197.     text_line *display_baseline;    /*pointer to first line to display in the widget*/
  198.     short sel_start_char;            /* Selected text pointers */
  199.     short sel_end_char;
  200.     text_line *sel_start_line;
  201.     text_line *sel_end_line;
  202. } text_widget;
  203.  
  204. /* Window Widget callback names */
  205.  
  206. #define WIDGET_CLOSE        1
  207. #define WIDGET_FULL            2
  208. #define WIDGET_ICONIFY        3
  209. #define WIDGET_RESIZE        4
  210. #define WIDGET_H_SLIDE        5
  211. #define WIDGET_V_SLIDE        6
  212. #define WIDGET_ARROW_UPPAGE    0|128
  213. #define WIDGET_ARROW_DNPAGE    1|128
  214. #define WIDGET_ARROW_UPLINE    2|128
  215. #define WIDGET_ARROW_DNLINE    3|128
  216. #define WIDGET_ARROW_LFPAGE    4|128
  217. #define WIDGET_ARROW_RTPAGE    5|128
  218. #define WIDGET_ARROW_LFLINE    6|128
  219. #define WIDGET_ARROW_RTLINE    7|128
  220.  
  221. typedef struct {
  222.     CallBack close_widget;
  223.     CallBack full_widget;
  224.     CallBack iconify_widget;
  225.     CallBack resize_widget;
  226.     CallBack h_slide;
  227.     CallBack v_slide;
  228.     CallBack arrows[8];
  229. } window_widget_response;
  230.  
  231. /*
  232.     The main object extented info structure.
  233.     This is a list objects in a given dialog, giving for each object:
  234.     events,callbacks,keyhandler,redraw,popup-icon info,scroll widget & text widget info.
  235.     Even if not all of these are use by a given object, it was easier to simply
  236.     maintain them all for each object rather than have to keep seperate lists.
  237. */
  238. typedef struct ml {
  239.     struct ml* next;            /*next in list*/
  240.     short object;                /*object that this event is for*/
  241.     event this_event;            /*event code (single click)*/
  242.     event this_devent;            /*event code (double click)*/
  243.     CallBack callback;            /*callback function for this object (single click)*/
  244.     CallBack dcallback;            /*callback function for this object (double click)*/
  245.     CallBack Kcallback;            /*callback funtion for this object (keypress) */
  246.     CallBack redraw;            /*custom redraw function for this object*/
  247.     short popup_form;            /*form for icon_popups containing other related icons*/
  248.     short popup_icon_current;    /*current object number of icon to display*/
  249.     scroll_text stext;            /*scrolling list details (if applicable)*/
  250.     text_widget wtext;            /*text edit widget details (if applicable)*/
  251. } Elist;
  252.  
  253. /* structure containing details of a window */
  254. typedef struct {
  255.     Dmode redraw_mode;
  256.     Wtype window_type;
  257.     short the_dialog;
  258. } Wdetails;
  259.  
  260. /* structure containing config info about a dialog */
  261. typedef struct {
  262.     short focus_mode;                        /*keyhandler focus mode for dialog - either FOCUS_MOUSE or FOCUS_FIELD*/
  263.     short current_focus;                    /*object that currently has keyboard focus in the dialog*/
  264.     char help_topic[30];                    /*subject for hypertext help (if available) */
  265.     window_widget_response wind_widgets;    /*handlers for the window widgets*/
  266. } Ddetails;
  267.  
  268. typedef enum { c_arrow,c_cross,c_circle,c_smiley,c_mover,c_arc,c_pointer } mouse_shape;
  269.  
  270. extern short junk;
  271. extern short messB[40];
  272. extern short timeB[40];
  273. extern short AESid;                            /* Our AES id */
  274. extern short AESversion;                    /* Current AES version */
  275. extern short AESversion_m;                    /* Current AES version (minor revision number)*/
  276. extern short x_handle;                        /* Automatically opened VDI workstation for us to work on */
  277. extern Wdetails windows[max_windows];
  278. extern Elist *event_value[max_dialogs];
  279. extern Ddetails dialog_details[max_dialogs];
  280. extern Elist *key_values;
  281. extern mouse_shape wm_mouse_shape;
  282. extern short wm_inv[512],wm_outv[200];
  283. extern short menu;                             /*The menubar form number*/
  284. extern short last_opened_window;            /*The handle of the last handle opened by activate_dialog*/
  285. extern short d_parm;                        /*Any parameter which has to be returned by a dialog (eg slider pos.)*/
  286. extern short udx,udy,udw,udh,icon_x,icon_y;
  287. /* All callback globals */
  288. extern short this_ob,this_dialog;            /*The current object handle when any callback routine is called*/
  289. /* Key triggered callbacks */
  290. extern short kc_key;                        /* AES key code */
  291. extern short kc_shstate;                    /* Keyboard shift state */
  292. /*Redraw globals */
  293. extern short cr_wind_handle;                /*Custom redraw - window containing object */
  294. extern GRECT cr_clip;                        /*Custom redraw object locations*/
  295. extern GRECT cr_dclip;                        /*Custom redraw object display clip rectangle*/
  296. extern short cr_mx,cr_my;                    /*Custom redraw/callback relative mouse location inside object*/
  297. /*Specific to scroll texts */
  298. extern short scroll_selection;                /*index in text to string when a scroll text has been clicked on */
  299. /* General information globals */
  300. extern short scrn_x,scrn_y,scrn_w,scrn_h;    /*screen - dimensions*/
  301. extern short scrn_planes;                    /*screen - number of bitplanes*/
  302. extern short wmi_total_buffering;
  303. extern CallBack XaccTextHandler;            /*handler routine for Xacc2 text transfers*/
  304. extern short click_count;                    /*number of mouse click events from last evnt_multi()*/
  305. /* Configuration variables */
  306. extern short RightClickEqualsDoubleClick;    /*a right button click has same effect as a double click if this is set to TRUE*/
  307. extern short ScrollSelectionIsInverse;        /*selected item in a scrolling list is shown in inverse*/
  308. extern short KeypressToWindowUnderMouse;    /*control how the keyboard handler behaves */
  309. /*Clipboard stuff*/
  310. extern char clipboard_path[FMSIZE+10];        /*path to the GEM clipboard*/
  311. /*Timer called routine stuff*/
  312. extern short timer_rate;
  313. extern CallBack timer_callback;
  314.  
  315. /*
  316.   =============================
  317.    The DU_LIB Library Routines
  318.   =============================
  319. */
  320.   
  321. /*DULIB.C*/
  322. short enviroment_initialise(void);        /* setup the system prior to use */
  323. short close_down();                        /* Shutdown a program, closing all windows and removing the menu bar */
  324. short install_menu(short m);            /* Install a GEM menu bar at the top of the screen */
  325. event WaitEvent(void);                    /* The Main event loop */
  326. event PollEvent(short t_poll);            /* Poll for events */
  327.  
  328. /*PROC_MSG.C*/
  329. event process_message(short mb[]);                        /* Process a GEM message */
  330. short redraw_window(short wind_handle);
  331. short custom_redraw_window(short wind_handle);
  332. void Set_dialog_widget_callback(short dialog, short widget, CallBack c);
  333.  
  334. /*EVENTS.C*/
  335. event Get_object_event(short dialog, short ob);                /*Get an event code for an object in a dialog (single click)*/
  336. short Set_object_event(short dialog, short ob, event e);    /* Set an event code for an object (single click)*/
  337. event Get_object_devent(short dialog, short ob);            /*Get an event code for an object in a dialog (double click)*/
  338. short Set_object_devent(short dialog, short ob, event e);    /* Set an event code for an object (double click)*/
  339. CallBack Get_object_callback(short dialog, short ob);        /* Get the address of a callback routine for an object (single click)*/
  340. short Set_object_callback(short dialog, short ob, CallBack c);    /* Set the address of a callback routine for an object (single click)*/
  341. CallBack Get_object_dcallback(short dialog, short ob);        /* Get the address of a callback routine for an object (double click)*/
  342. short Set_object_dcallback(short dialog, short ob, CallBack c);    /* Set the address of a callback routine for an object (double click)*/
  343. CallBack Get_dialog_Kcallback(short dialog);                /*Get addr of a dialog general key handler */
  344. short Set_dialog_Kcallback(short dialog, CallBack c);        /*Set addr of a dialog general key handler */
  345. CallBack Get_object_Kcallback(short dialog, short ob);        /*Get addr of a specific object key handler */
  346. short Set_object_Kcallback(short dialog, short ob, CallBack c); /*Set addr of a specific object key handler */
  347. CallBack Get_key_callback(short key);                        /*Get a specific key callback */
  348. short Set_key_callback(short key, CallBack c);                /*Set a specific key callback */
  349. CallBack Get_object_redraw(short dialog, short ob);
  350. short Set_object_redraw(short dialog, short ob, CallBack c);
  351. short find_event(short dialog,short ob, Elist *ee[1]);        /* Find an object's callback/event entry */
  352. Elist* new_event_struct(short dialog, short ob);            /* Create & initialise a new event structure for an object in a dialog */
  353.  
  354. /*WINDIAL.C*/
  355. short set_window_title(short h, char *a);                    /* Set the title of a window */
  356. short activate_dialog(short dialog, char *n, dialog_type t);/* Activate a windowed dialog */
  357. short display_dial(short wind_handle);                        /* Display the dialog associated with window wind_handle */
  358. short custom_display_dial(short wind_handle);                /* Display only the custom redraw objects associated with a window */
  359. short wind_display_object(short wind_handle, short object);
  360. int intersection(short x1,short y1,short w1,short h1,short x2,short y2,short w2,short h2,short *x,short *y,short *w,short *h);
  361. short close_dialog(short dialog);                            /* Close all copies of a dialog */
  362. short close_dialog_window(short e_wind);                    /* Close a dialog window */
  363. short dialog_update(short d);                                /* Update a dialog using AES redraw messages (if it is open)*/
  364. short dialog_display(short d);                                /* Redraw a dialog immediately (if it is open)*/
  365. short dialog_object_display(short d, short o);
  366. short process_win_dial(short wh,short x,short y);
  367. short Radio_b(OBJECT *t, short object);
  368. short GetParent(OBJECT *t,short object);
  369. short Get_ob_info(OBJECT *dialog,short ob,short *otype,short *oflags,short *ostate);
  370. short set_dialog_text(short dialog, short object, char* t);    /* Sets a text object in a dialog to a given string*/
  371. int redraw_custom(short wind_handle);
  372. short custom_display_object(short wind_handle, short ob);    /* Display only a specified custom redraw object associated with a window */
  373.  
  374. /*MESSAGES.C*/
  375. int update_window(short wind_handle);                        /* Update a window by sending ourselves a wm_redraw message via GEM.*/
  376. int custom_update_window(short wind_handle);                /* Update a window by sending a WM_CUSTOM_REDRAW message to only redraw custom objects */
  377. int send_redraw(short sx, short sy,short sw,short sh);        /* Send redraw messages to all our windows for the area (sx,sy,sw,sh)*/
  378. int I_send_message(short wind_handle, short msg);            /* Send ourselves a control message via GEM.*/
  379. short Set_XaccTextHandler(CallBack c);                        /* Set a callback routine to handle any Xacc2 ACC_TEXT messages */
  380.  
  381. /*POPUP.C*/
  382. short form_popup(short dialog,short object, short n, short current, char* t[1]);    /*Form an <n> entry pop-up menu for <object> in <dialog>, and return a selection from it.*/
  383.  
  384. /*S_LIST.C*/
  385. short Set_scroll_list(short dialog, short ob, short event, char *text_list[], short nt, short nd);
  386. short Change_scroll_list(short dialog, short ob, char *text_list[], short nt);
  387. short SelectFromScrollList(void);
  388. short DisplayScrollList(void);
  389. short Get_object_scroll(short dialog, short object, char *(*t[]), short *start, short *nt, short *nd, short *current);
  390. short ScrollListDrag(void);
  391. short ScrollListDown(void);
  392. short ScrollListUp(void);
  393.  
  394. /*IPOPUP.C*/
  395. void Set_icon_popup(short dialog, short object, short p_form);
  396. short Get_icon_popup(short dialog, short object);
  397. short do_icon_popup(void);
  398. short display_p_icon(void);
  399.  
  400. /*MODE.C*/
  401. void DU_mode(ModeType mt, short m);
  402.  
  403. /*TEXTEDIT.C*/
  404. void Set_text_widget(short dialog, short ob, short max_columns, short max_lines);
  405. void Change_widget_text(short dialog, short ob, char *t[], short lines);
  406. short Get_widget_text(short dialog, short ob, char ***text, short text_lines);
  407. short TW_display(void);
  408. short TW_keypress(void);
  409. short TW_mouse_click(void);
  410.  
  411. /*STDKEY.C*/
  412. void Set_standard_keyboard(void);
  413. short std_key_close_window(void);
  414. short std_key_cycle_window(void);
  415.  
  416. /*ED_TEXT.C*/
  417. void Set_object_editable(short dialog,short object);
  418. void Set_dialog_Kfocus_policy(short dialog, short focus_policy);
  419. void Set_dialog_Kfocus(short dialog, short object);
  420. short ted_callback(void);
  421. short ted_display_cursor(void);
  422. short ted_mouseclick(void);
  423.  
  424. /*TIMER.C*/
  425. void Set_timer_callback(short t, CallBack c);
  426.  
  427. /*STG_HELP.S*/
  428. void Set_application_helpfile(char *h);
  429. void Set_dialog_help_topic(short dialog, char *h);
  430. short dialog_help(void);
  431.  
  432. /*============= RESOURCE.C ==============*/
  433. void rsrc_form2mono(short d,short b);    /* Convert a colour form into a mono one */
  434. void *LoadResources(char *fname,short designWidth,short designHeight);
  435. void FreeResources(void *base);
  436. OBJECT *ResourceTree(void *base,short num);
  437. char *ResourceString(void *base,short num);
  438. void *ResourceImage(void *base,short num);
  439. int DUrsrc_load(char *n);
  440. int DUrsrc_free(void);
  441. int DUrsrc_gaddr(int type, int index, void *addr);
  442.  
  443. /*
  444.     Simulate the standard GEM AES resource access functions using Steve Sowerby's
  445.     resource routines.
  446. */
  447. #undef rsrc_load
  448. #undef rsrc_free
  449. #undef rsrc_gaddr
  450. #define rsrc_load    DUrsrc_load
  451. #define rsrc_free    DUrsrc_free
  452. #define rsrc_gaddr    DUrsrc_gaddr
  453. /*
  454.    I only ever use the R_TREE mode of rsrc_gaddr, so I define this to get a
  455.    bit of extra speed - undefine this symbol if you want to use R_STRING & R_IMAGEDATA
  456.    as well
  457. */
  458. #define RSRC_GADDR_ONLY_TREES
  459.  
  460. #ifdef _DULIB_FOR_MINT
  461.  
  462. /*MINTPAT.C*/
  463. void _XCEXIT(void);
  464.  
  465. /*COOKIE.S*/
  466. int getcookie(long,long *);
  467.  
  468. #endif
  469.  
  470. #endif
  471.